<?php echo $this->render('link/header.phtml') ?>



//常用变量初始化
var menuDelUrl=baseUrl+"/link/serverarticle/type/del";
var menuEditUrl=baseUrl+"/link/serverarticle/type/edit";
var module="article";
var gridTitle="软文列表";
var dataId="article_id";
var article = Ext.data.Record.create([
           {name: 'article_id', type: 'int'},
           {name: 'article_title', type: 'string'},
		   {name: 'article_content', type: 'string'},
           {name: 'article_tags', type: 'string'}
      ]);


                                       
var ds=new Ext.data.Store({
							  proxy:new Ext.data.HttpProxy({
									url:baseUrl+'/link/serverarticle/'
									}),
							  reader:new Ext.data.JsonReader({
									root:'results',
									totalProperty:'total',
									id:'u_id'
									},article)
	});		 
//定义列模型
var cm=new Ext.grid.ColumnModel([	
							new Ext.grid.RowNumberer(),	
                            {header:'文章ID',dataIndex:'article_id',width:60,hidden:true},                           														
							{header:'标题',dataIndex:'article_title',width:220,editor:new Ext.form.TextField({allowBlank:false})},
							{header:'内容',dataIndex:'article_content',width:600,renderer:show_content,editor:new Ext.form.HtmlEditor({allowBlank:false})},                          
							{header:'Tags',dataIndex:'article_tags',width:200,editor:new Ext.form.TextField({allowBlank:false})},
                            {header:"操作",dataIndex:'article_id',renderer:show_button}
	]);
cm.defaultSortable = true; 





//定义工具栏								 
var tb=new Ext.Toolbar({
							items:[
								<?php if($this->acl->isAllowed($this->role,'link','articleAdd')) {?>
                                         {
                                            id:'menuDel'+ExtId,
											text:'删除',
											iconCls:'icn-delete',
											handler:menuDel
											},
                                <? } ?>
                                <?php if($this->acl->isAllowed($this->role,'link','articleEdit')) {?>
                                           {
											id:'menu_save'+ExtId,
											text:'保存',	
											iconCls:'icn-edit',
											disabled:true,
											handler:menuSave
											},{
											xtype:'tbfill'
											},
                                 <? } ?>
                                <?php if($this->acl->isAllowed($this->role,'link','articleAdd')) {?>           
                                            {
                                            id:'menu_quickadd'+ExtId,
											text:'快速添加',
											iconCls:'icn-add',
											handler:menuAddQuick
										}
                                 <? } ?>
											 
								 ]
	});			
   
function  menuAdd(){

}		
function menuAddQuick(){
	
	var n = grid.getStore().getCount();// 获得总行数
                var p = new article({
                   article_title:'  ',
                   article_content:' ',
                   article_tags:''
                });
                grid.stopEditing();// 停止编辑
                ds.insert(n, p);// 插入到最后一行
                grid.startEditing(n, 1);// 开始编辑1单元格
				Ext.getCmp('menu_save'+ExtId).setDisabled(false);
	}


function show_button(val){
	return "<a href='javascript:void(0)' onclick=javascript:add_tab('引用软文',baseUrl+'/link/articlereference/id/"+val+"','article/reference/id/"+val+"')>引用软文</a>";
    
}			      
<?php echo $this->render('link/foot.phtml') ?>
